package com.meilingcloud.web.controller.statistics;

import com.meilingcloud.biobank.domain.dto.StatisticDto;
import com.meilingcloud.biobank.service.IContainerService;
import com.meilingcloud.biobank.service.ISampleBackupService;
import com.meilingcloud.biobank.service.ISourceService;
import com.meilingcloud.common.core.domain.AjaxResult;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/statistics")
public class StatisticsController {

    private final ISampleBackupService iSampleBackupService;
    private final IContainerService iContainerService;
    private final ISourceService iSourceService;

    /**
     * 根据样本类型统计
     */
    @GetMapping("/chartByType/{sampState}")
    public AjaxResult chartByType(@PathVariable("sampState") String sampState) {
        return AjaxResult.success(iSampleBackupService.chartByType(sampState));
    }

    /**
     * 根据样本源类型统计
     */
    @GetMapping("/chartBySourceType/{sampState}")
    public AjaxResult chartBySourceType(@PathVariable("sampState") String sampState) {
        return AjaxResult.success(iSampleBackupService.chartBySourceType(sampState));
    }

    /**
     * 根据样本组统计
     */
    @GetMapping("/chartByGroup/{sampState}")
    public AjaxResult chartByGroup(@PathVariable("sampState") String sampState) {
        return AjaxResult.success(iSampleBackupService.chartByGroup(sampState));
    }

    /**
     * 根据创建人统计
     */
    @GetMapping("/chartByCreator/{sampState}")
    public AjaxResult chartByCreator(@PathVariable("sampState") String sampState) {
        return AjaxResult.success(iSampleBackupService.chartByCreator(sampState));
    }

    /**
     * 根据采样时间统计
     */
    @GetMapping("/chartBySamplingTime")
    public AjaxResult chartBySamplingTime(StatisticDto dto) {
        return AjaxResult.success(iSampleBackupService.chartBySamplingTime(dto));
    }

    /**
     * 根据出入库时间统计
     */
    @GetMapping("/chartByStockTime")
    public AjaxResult chartByStockTime(StatisticDto dto) {
        return AjaxResult.success(iSampleBackupService.chartByStockTime(dto));
    }

    /**
     * 过期样本统计
     */
    @GetMapping("/chartByExpired")
    public AjaxResult chartByExpired() {
        return AjaxResult.success(iSampleBackupService.chartByExpired());
    }

    /**
     * 根据样本类型统计报表
     */
    @GetMapping("/reportBySampType")
    public AjaxResult reportBySampType(StatisticDto dto) {
        return AjaxResult.success(iSampleBackupService.reportBySampType(dto));
    }

    /**
     * 根据样本源类型统计报表
     */
    @GetMapping("/reportBySourceType")
    public AjaxResult reportBySourceType(StatisticDto dto) {
        return AjaxResult.success(iSampleBackupService.reportBySourceType(dto));
    }

    /**
     * 根据样本组统计报表
     */
    @GetMapping("/reportBySampGroup")
    public AjaxResult reportBySampGroup(StatisticDto dto) {
        return AjaxResult.success(iSampleBackupService.reportBySampGroup(dto));
    }

    /**
     * 根据样本类型统计在库数量和使用数量
     */
    @GetMapping("/statisticByType")
    public AjaxResult statisticByType() {
        return AjaxResult.success(iSampleBackupService.statisticByType());
    }

    /**
     * 统计各容器样本数量
     */
    @GetMapping("/statisticContainer")
    public AjaxResult statisticContainer() {
        return AjaxResult.success(iContainerService.statisticContainer());
    }

    /**
     * 根据样本源类型统计
     */
    @GetMapping("/statisticSource")
    public AjaxResult statisticSource() {
        return AjaxResult.success(iSourceService.statisticSource());
    }

    /**
     * 统计样本总数
     */
    @GetMapping("/statisticSampleCount")
    public AjaxResult statisticSampleCount() {
        return AjaxResult.success(iSampleBackupService.statisticSampleCount());
    }

    /**
     * 统计样本源总数
     */
    @GetMapping("/statisticSourceCount")
    public AjaxResult statisticSourceCount() {
        return AjaxResult.success(iSourceService.statisticSourceCount());
    }

}
